package com.apps.shelper;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Parameter;
import java.util.HashMap;
import java.util.Map;

/**
 * 切面帮助类
 */
public class AspectHelper {

    /**
     * 找出切点方法的所有传参
     * @param point
     * @return
     */
    public static Map<String,Object> handlerParameter(JoinPoint point){
        Map<String,Object> result=new HashMap<>();
        MethodSignature methodSignature = (MethodSignature)point.getSignature();
        Parameter[] parameter=methodSignature.getMethod().getParameters();
        Object[] args = point.getArgs();
        for(int i=0;i<parameter.length;i++)
        {
            String parameterName=methodSignature.getParameterNames()[i];
            result.put(parameterName,args[i]);
        }
        return result;
    }
}
